#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <stdlib.h>
int main()
{
	printf("我的程序要运行了!\n");
	if (fork() == 0)
	{
		sleep(1);
		//脚本语言执行的程序是解释器
		//execl("/usr/bin/python3", "python", "other.py", NULL);
		//execlp("ls", "ls", "-l", "-a", NULL);
		//char *const argv[] = {
		//	(char*const)"ls",
		//	(char*const)"-l",
		//	(char*const)"-a",
		//	NULL
		//};
		//execv("/usr/bin/ls", argv);
		//execl("/usr/bin/bash", "bash", "other.sh", NULL);
		//execl("./other", "other", NULL);
		
		char *const argv[] = {
			(char*const)"other",
			(char*const)"-a",
			(char*const)"-b",
			NULL
		};
		char *const env[] = {
			(char*const)"MYVAL=123456789",
			NULL
		};
		execvpe("./other", argv, env);
		exit(1);
	}
	waitpid(-1, NULL, 0);
	printf("我的程序运行完毕!\n");
	return 0;




	//printf("我的程序要运行了!\n");
	//int i = execl("/usr/b/ls", "ls", "-l", "-a", NULL);
	//printf("我的程序运行完毕!，返回值为：%d\n", i);
	//return 0;
}
